% GAUTIER LE BIHAN - 2020
% Replication files for "Shocks vs Menu Costs: Patterns of Price Rigidity in an Estimated Multi-Sector 
% Menu-Cost Model" Review of Economics and Statistics
% Compute additional simulated moments for Appendix figure D

clear;
tic

NSectors = 1;
sm = 0.0;
addpath('..\..\Utilities')  


p0=[0.004:0.003:0.065]';
mu_c=[0.003:0.002:0.055]';
sig_eps=[0.033:0.0015:0.065]';
rho_a=[0.60:0.02:0.95]';
s=size(p0,1)+size(mu_c,1)+size(sig_eps,1)+size(rho_a,1)
 


for kk=3:3;
 
     fprintf("kk");
     disp(kk);

p0=[0.004:0.003:0.065]';
mu_c=[0.003:0.002:0.055]';
sig_eps=[0.033:0.0015:0.065]';
rho_a=[0.60:0.02:0.95]';

s=size(p0,1)+size(mu_c,1)+size(sig_eps,1)+size(rho_a,1)   
     
if kk==1;
param0=[tanh(0.0490584431344758); 0.0315640909562270; exp(-3.26389330290137); tanh(0.781262143955240)];
end;
if kk==2;
param0=[0.0001; 0.0315640909562270; exp(-3.26389330290137); tanh(0.781262143955240)];
end;
if kk==3;
param0=[0.0001; 0.0315640909562270; exp(-3.26389330290137)/2; tanh(0.781262143955240)];
end;
%param0=[0.0518 ;   0.0413;   0.0745  ; 0.1023];
%0.0518    0.0412    0.0745    0.1020%
param=repmat(param0,1,s)';

param(1:size(p0),1)=p0;
param(size(p0)+1:size(p0)+size(mu_c),2)=mu_c;
param(size(p0)+size(mu_c)+1:size(p0)+size(mu_c)+size(sig_eps),3)=sig_eps;
param(size(p0)+size(mu_c)+size(sig_eps)+1:size(p0)+size(mu_c)+size(sig_eps)+size(rho_a,1),4)=rho_a;


mu_vec=0.00125;

size_mu=1;
for ii=1:size_mu;
    
mu_loop=mu_vec*ii;
     fprintf("ii");
     disp(ii);
%for jj=1+s*(ii-1):ii*s;
for jj=1:s;
     fprintf("jj");
     disp(jj);
     %"i" i);
    p0=param(jj,1);
    mu_c=param(jj,2);
    sig_eps_a=param(jj,3);
    %p_a=param(jj,4); 
    rho_a=param(jj,4);
    weight_j=0.57;    
 
 %  [f2, avfracup2,    med2,med21,med22, wmed1p, wmed1n, wmed2p, wmed2n, wmoy1p, wmoy1n, wmoy2p, wmoy2n,   interq2, kur2]=geNCalvoPlus_SMM(mu_loop, p0, mu_c, sig_eps_a, rho_a, weight_j);
   [f2, avfracup2,    med2,med21,med22,   interq2, kur2]=geNCalvoPlus_SMM(mu_loop, p0, mu_c, sig_eps_a, rho_a, weight_j);
    stat_temp(jj,:)=[kk param(jj,:) f2 avfracup2 med2 interq2 kur2 med21  med22]


end


end

stat_outc(1+s*(kk-1):kk*s,:)=stat_temp
save stat_outc stat_outc;
end